package org.szt.humwiki.page.dao;

import java.util.List;

import javax.sql.DataSource;

import org.springframework.jdbc.core.JdbcTemplate;
import org.szt.humwiki.page.WikiPage;

public class PageDAO {
	private JdbcTemplate jdbcTemplate;

	public void setDataSource(DataSource dataSource) {
		this.jdbcTemplate = new JdbcTemplate(dataSource);
	}

	public WikiPage getPage(String name) {
		List<WikiPage> pages = jdbcTemplate.queryForList(
				"select * from w_page where name= ? ", new Object[] { name },
				WikiPage.class);
		if (pages.size() > 0) {
			return pages.get(0);
		}
		return null;
	}

	public void save(WikiPage page) {
		if(page.getId()==null){
			//insert
			
		}else{
			//update
			
		}
	}
}
